package com.zd.web.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.zd.entity.User;
import com.zd.service.MessageService;
import com.zd.service.impl.MessageServiceImpl;

/**
 * Servlet implementation class InsertLikeservlet
 */
@WebServlet("/InsertLikeservlet")
public class InsertLikeservlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		request.setCharacterEncoding("UTF-8");
		String novelid=request.getParameter("novelid");
		User user=(User)request.getSession().getAttribute("user");
		int userId=user.getUserId();
		response.setContentType("application/text");
		MessageService messageservice=new MessageServiceImpl();
		int novelid1=messageservice.insertlike(userId,Integer.parseInt(novelid));
		
		
		PrintWriter out=response.getWriter();
		out.print(novelid1);
		out.flush();
		out.close();
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
